const fs = require('fs');
const path = require('path');

const projectPath = '/Users/zhangyue/projects/jiaju/wechat_app_yonghu';

function listFiles(dir, fileList = []) {
    const files = fs.readdirSync(dir);
    files.forEach(file => {
        const filePath = path.join(dir, file);
        if (fs.statSync(filePath).isDirectory()) {
            fileList = listFiles(filePath, fileList);
        } else {
            fileList.push(filePath);
        }
    });
    return fileList;
}

const allFiles = listFiles(projectPath);
const unusedFiles = allFiles.filter(file => {
    // 检查文件是否在代码中被引用，简单示例可以使用正则表达式或其他方法
    const content = fs.readFileSync(file, 'utf-8');
    return !allFiles.some(otherFile => otherFile !== file && fs.readFileSync(otherFile, 'utf-8').includes(path.basename(file)));
});

console.log('Unused files:', unusedFiles);
